<!--suppress ALL -->
<template>
  <view class="form">
      <Form :type="pageTyep" @submit="submit" v-if='pageCheck === 0' ref="baseForm"></Form>
      <view class="formINFO" ref="HotWork">
        <!--			<base-form v-model="formModel" :labelWidth="100" :formList="formList" :btnMessage="btnMessage"-->
        <!--				@submit="submit" v-if='pageCheck === 0'>-->
        <!--			</base-form>-->
        <hazardousCheck v-if="pageCheck === 1 " @whbsSubmit="cardSubmit" :pageCheck="pageCheck" ></hazardousCheck>
        <protectionCheck v-else-if="pageCheck === 2" :pageCheck="pageCheck" @grfhSubmit='grfh'></protectionCheck>
        <safetyCheck v-else-if="pageCheck === 3" :pageCheck="pageCheck" @aqcsSubmit='aqcs'></safetyCheck>
        <Gas v-else-if="pageCheck === 4" :pageCheck="pageCheck" @fzr="fzr" :pageTyep="pageTyep"></Gas>
        <Reviewer v-else-if="pageCheck === 5" :pageCheck="pageCheck" :form="form" :pageTyep="pageTyep"></Reviewer>
      </view>
  </view>
</template>

<script>
import deptPick from "@/pages/Components/department";
import {
  workHeaderAPI
} from '@/api/public.js'
import hazardousCheck from '../components/hazardousCheck/hazardousCheck'
import protectionCheck from '../components/protectionCheck/protectionCheck'
import safetyCheck from '../components/safetyCheck/safetyCheck'
import Gas from '../components/gas/gas'
import Reviewer from '../components/Reviewer/Reviewer'
import Form from '@/pages/Components/formMessage/formMessage'

export default {
  components: {
    deptPick,
    hazardousCheck,
    protectionCheck,
    safetyCheck,
    Gas,
    Reviewer,
    Form
  },
  data() {
    return {
      pageCheck: 0,
      pageTyep: 7,
      btnMessage: {
        state: false,
        cancels: '上一步',
        submit: '下一步',
      },
      formModel: {
        name: "",
        userPicker: "",
        datetime: "",
        picker: "",
      },
      formList: [],
      form:{
        list:null,
        whbsIds:null,
        grypfhIds:null,
        aqcsIds:null,
        qmtp:null,
        ry:uni.getStorageSync('userId'),
        orgCode:uni.getStorageSync('companyId')
      },
    }
  },

  methods: {
    submit(val){
      this.form.list = val.list
      this.form.params = val.params
      this.pageCheck++
    },
    fzr(val){

      this.form.qmtp = val.fileUrl
      this.form.qzy = val.value
      this.pageCheck = val.step
    },
    cardSubmit(val) {
      let msg = val.value.map((e)=>{
        return e.value
      })
      this.form.whbsIds = msg.toString()
      this.pageCheck = val.step
    },
    grfh(val) {
      let msg = val.value.map((e)=>{
        return e.value
      })
      this.form.grypfhIds = msg.toString()
      this.pageCheck = val.step
    },
    aqcs(val) {
      let msg = val.value.map((e)=>{
        return e.value
      })
      this.form.aqcsIds = msg.toString()
      this.pageCheck = val.step
    },
    URL(val) {
      this.pageCheck = val
    },
  }
}
</script>
<style lang="scss" scoped>
.form {
  height: 100vh;
  overflow-y: auto;

  background: #f6f6f6;

  .formINFO {
    border-radius: 8px;
    background: #FFF;
    padding: 0 45rpx;
    margin: 50rpx 30rpx;
  }
}
</style>
